package net.xju.entity;

import lombok.*;
import net.xju.common.utils.DateUtils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

//使用lombok来设置getter和setter方法，创建toString方法，创建无参构造，创建有参构造

@NoArgsConstructor              //创建无参构造
@AllArgsConstructor             //创建有参构造
@Getter                         //创建getter方法
@Setter                         //创建setter方法
@ToString                       //创建toString方法
public class Goods {

    private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");    //  1. LocatDateTime类型的转 str

    private Integer id;
    private String name;
    private Integer price;
    private Date pubdate;
    private Integer typeId;
    private String intro;
    private String picture;
    private Integer flag;
    private Integer deleted;
    private LocalDateTime createTime;

    private String createTimeStr;
    private String pubdateStr;

    public String getPubdateStr() {
        return DateUtils.parseDate2Str(pubdate);
    }

    public String getCreateTimeStr() {
        return createTime!=null?createTime.format(formatter):"";
    }
}
